
const myTools = {
  // 返回每日新闻的日期 格式：YY-MM-DD
  getData () {
    const dd = new Date()
    let yy = dd.getFullYear()
    let mm = dd.getMonth() + 1
    let rr = dd.getDate()
    let m = mm < 10 ? '0' + mm : mm
    let r = rr < 10 ? '0' + rr : rr
    return yy + '-' + m + '-' + r
  },
  getHourAndMinute () {
    let dd = new Date()
    let hour = dd.getHours()
    let minute = dd.getMinutes()
    hour = hour < 10 ? '0' + hour : hour
    minute = minute < 10 ? '0' + minute : minute
    return hour + ':' + minute
  },
  getRandomIndex (end) {
    let rand = Math.floor(Math.random() * end)
    return rand
  },
  myRegForQQInfo (str) {
    let imgReg = /(?<=(src="))[^"]*?(?=")/ig
    let nameReg = /(?<=昵称：).*?(?=<)/gi
    let emailReg = /[1-9][0-9]{4,10}@qq.com$/
    let img = str.match(imgReg)[0]
    let qq_name = str.match(nameReg)[0]
    let email = str.match(emailReg)[0]
    return [qq_name, email, img]
  }
}


exports.tools = myTools
